home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / window2.zip / WNDEMO.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  3KB  |  107 lines

  1. #include <stdio.h>
  2. #include <window.h>
  3.  
  4. #define HOME        0x8A    /* HOME key    */
  5. #define CURLF        0x8B    /* <-        */
  6. #define ENDKEY        0x8C    /* END key    */
  7. #define CURRT        0x9B    /* ->        */
  8. #define INSERT        0x9D    /* Ins        */
  9. #define DELETE        0x9E    /* Del        */
  10.  
  11.     /*************************************
  12.     ** window.c and vlib.a functions    */
  13.  
  14. WINDOWPTR    draw_window();
  15. void        write_text(), clr_window(), remove_window();
  16. void        delete_row(), gotoxy(), vputc();
  17. char        kbd_ci(), kbd_csts();
  18. int            ticker();
  19.  
  20.     /*********************
  21.     ** desmet functions    */
  22.  
  23. char        csts(), ci(), co();
  24. int            isprint();
  25.  
  26. main()    /* demonstration */
  27. {
  28.     int            i,j,k;
  29.     WINDOWPTR    wn, wn2;
  30.     char        linbuf[135];
  31.  
  32.     while ( 1 )
  33.     {    for ( i=0; i<50; i++ )
  34.         {    puts("Hit ESC while this display is moving to exit.  ");
  35.             brkchk ( 0 );
  36.         }
  37.  
  38.         if ( (wn2 = draw_window(45, 5, 30, 10, 0x50)) == NULL)
  39.         {    puts("\n\nUnable to open window for help\n");
  40.             exit(1);
  41.         }
  42.         win_text ( wn2, "   Editing keys\n   ------------\n");
  43.         win_text ( wn2, "Cursor   ->,<-,Home,End,^S,^D\n");
  44.         win_text ( wn2, "Erase    Del,Backspace(<--),^G\n");
  45.         win_text ( wn2, "Mode     Ins,^V (toggles)\n\n");
  46.         win_text ( wn2, "Done     Enter\n");
  47.  
  48.         if ( (wn = draw_window(10, 3, 30, 1, 0x30)) == NULL)
  49.         {    puts("\n\nUnable to open window for input\n");
  50.             exit(1);
  51.         }
  52.         win_text ( wn2, "\n\nResult may be up to 20 chars" );
  53.         win_text ( wn,"Enter new data: " );
  54.         linbuf[0] = '\0';
  55.         j = ticker(wn->uly+1,wn->ulx+1+17,linbuf,20,12,wn->wpage);
  56.         remove_window ( wn );
  57.  
  58.         if ( (wn = draw_window(10, 15, 30, 1, 0x20)) == NULL)
  59.         {    puts("\n\nUnable to open window for edit\n");
  60.             exit(1);
  61.         }
  62.         win_text ( wn2, "\rResult may be up to 30 chars" );
  63.         win_text ( wn,"Edit old data: " );
  64.         j = wticker(wn,linbuf,30,31);
  65.         remove_window ( wn );
  66.         remove_window ( wn2 );
  67.  
  68.         if ( j )
  69.             printf("\n\nResponse was \"%s\".  ", linbuf);
  70.         else
  71.             puts("\n\nThe response was empty.  ");
  72.         puts("Press any key to continue:  ");
  73.         i = ci();
  74.     }
  75. }
  76.  
  77. int brkchk(n)
  78.  
  79.     int        n;
  80. {
  81.     WINDOWPTR    wn;
  82.     int            i;
  83.     char        c;
  84.  
  85.     if ( csts() == 0 )
  86.         return ( 0 );
  87.     i = ci();
  88.     if ( n && ( i != n ) )
  89.         return ( 0 );
  90.     if ( ( n == 0 ) && ( i != 27 ) )
  91.         return ( 0 );
  92.     if ( (wn = draw_window(20, 13, 25, 1, 0x40)) == NULL)
  93.         exit(1);
  94.     win_text ( wn,"\007  Enter \"Y\" to " );
  95.     if ( n )
  96.         win_text ( wn,"stop : " );
  97.     else
  98.         win_text ( wn,"exit : " );
  99.     co ( c = toupper ( ci() ) );
  100.     remove_window(wn);
  101.     if ( c != 'Y' )
  102.         return ( 0 );
  103.     if ( n )
  104.         return ( n );
  105.     exit(1);
  106. }
  107.